using RuoVea.ExEnum;
using RuoVea.ExSugar.Attributes;
using RuoVea.ExSugar.Entity;
using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace RuoVea.OmiApi.Reports.Models;

/// <summary>
/// 数据库配置信息
/// </summary>
[SugarTable(nameof(RptDatabase), "数据库配置")]
[SugarIndex($"IX_{nameof(RptDatabase)}_{nameof(Name)}", nameof(Name), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(RptDatabase)}_{nameof(IsEnabled)}", nameof(IsEnabled), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(RptDatabase)}_{nameof(CreateTime)}", nameof(CreateTime), OrderByType.Desc)]
public class RptDatabase : EntityBase
{
    /// <summary>
    /// 数据源名称
    /// </summary>
    [Required, MaxLength(100)]
    [ConfigSugarColumn(nameof(Name),columnDescription : "数据源名称")]
    public string Name { get; set; }

    /// <summary>
    /// 数据源连接字符串(JDBC)
    /// </summary>
    [Required, MaxLength(500)]
    [ConfigSugarColumn(nameof(ConnectionString),columnDescription : "连接字符串")]
    public string ConnectionString { get; set; }

    /// <summary>
    /// 数据源登录用户名
    /// </summary>
    [ConfigSugarColumn(nameof(User),columnDescription : "用户名", IsNullable = true)]
    public string User { get; set; }

    /// <summary>
    /// 数据源登录密码
    /// </summary>
    [ConfigSugarColumn(nameof(Password),columnDescription : "密码", IsNullable = true)]
    public string Password { get; set; }

    /// <summary>
    /// 数据库类型
    /// </summary>
    [ConfigSugarColumn(nameof(DataType),columnDescription : "数据库类型", IsNullable = true)]
    public int? DataType { get; set; }

    /// <summary>
    /// 连接池类型
    /// </summary>
    [ConfigSugarColumn(nameof(PoolType),columnDescription : "连接池类型", IsNullable = true)]
    public string PoolType { get; set; }

    /// <summary>
    /// 数据源配置选项(JSON格式）
    /// </summary>
    [ConfigSugarColumn(nameof(Options),columnDescription : "配置选项", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string Options { get; set; }

    /// <summary>
    /// 是否启用
    /// </summary>
    [ConfigSugarColumn(nameof(IsEnabled),columnDescription : "是否启用", DefaultValue = "1")]
    public YesOrNot? IsEnabled { get; set; } = YesOrNot.Y;

    /// <summary>
    /// 排序号
    /// </summary>
    [ConfigSugarColumn(nameof(Sort),columnDescription : "排序号", IsNullable = true, DefaultValue = "10")]
    public int? Sort { get; set; }


    /// <summary>
    /// 说明备注
    /// </summary>
    [ConfigSugarColumn(nameof(Remark),columnDescription : "备注", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string Remark { get; set; }

}